package cn.sgjk.train.business.controller.admin;


import cn.sgjk.train.common.context.LoginMemberContext;
import cn.sgjk.train.common.resp.CommonResp;
import cn.sgjk.train.common.resp.PageResp;
import cn.sgjk.train.business.req.TrainCarriageQueryReq;
import cn.sgjk.train.business.req.TrainCarriageSaveReq;
import cn.sgjk.train.business.resp.TrainCarriageQueryResp;
import cn.sgjk.train.business.service.TrainCarriageService;
import jakarta.validation.Valid;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/admin/train-carriage")
public class TrainCarriageAdminController {

    private static final Logger LOG = LoggerFactory.getLogger(TrainCarriageAdminController.class);
    @Autowired
    private TrainCarriageService trainCarriageService;



    @PostMapping("/save")
    public CommonResp<Object> save(@Valid @RequestBody TrainCarriageSaveReq trainCarriageReq) {
        trainCarriageService.save(trainCarriageReq);
        return new CommonResp<>();
    }



    @GetMapping("/query-list")
    public CommonResp<PageResp<TrainCarriageQueryResp>> query(@Valid TrainCarriageQueryReq trainCarriageQueryReq) {
        PageResp<TrainCarriageQueryResp> trainCarriageQueryResps = trainCarriageService.queryList(trainCarriageQueryReq);
        return new CommonResp<>(trainCarriageQueryResps);
    }

    @DeleteMapping("/delete/{id}")
    public CommonResp<Object> delete(@PathVariable Long id) {
        trainCarriageService.delete(id);
        return new CommonResp<>();
    }
}

